/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Interact;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import ConnectDB.ConnectDB;
import Validate_Connect.DataInteraction;
/**
 *
 * @author Shinichi
 */
public class SubjectSchedules {
    public static boolean insertSubjectSchedule(Entity.SubjectSchedule ssc){
        try {

            String sql = "insert into tblSubjectSchedule values(?,?)";
            PreparedStatement ps = DataInteraction.getConnect().prepareStatement(sql);
            ps.setInt(1, ssc.get_ScheduleID());
            ps.setString(2, ssc.get_SubjectID());
            return ps.executeUpdate() == 1;
        } catch (SQLException ex) {
            Logger.getLogger(SubjectSchedules.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }
    
    public static boolean updateSubjectSchedule(Entity.SubjectSchedule ssc){
        try {
            String sql = "update tblSubjectSchedule set SubjectID=? where ScheduleID=?";
            PreparedStatement ps = DataInteraction.getConnect().prepareStatement(sql);
            ps.setString(1, ssc.get_SubjectID());
            ps.setInt(2, ssc.get_ScheduleID());
            return ps.executeUpdate() == 1;
        } catch (SQLException ex) {
            Logger.getLogger(SubjectSchedules.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }        
    }
    
    public static void deleteSubjectSchedule(int intScheID){
        try {
            String sql = "delete from tblSubjectSchedule where ScheduleID = " + intScheID;
            Statement st;
            st = DataInteraction.getConnect().createStatement();
            st.executeUpdate(sql);
        } catch (SQLException ex) {
            Logger.getLogger(SubjectSchedules.class.getName()).log(Level.SEVERE, null, ex);
        }        
    }


}
